<?php
   include(dirname(__DIR__) . '/Driver.class.php');

   class Mysql implements Driver{

       private $conn;

       public function connet($config){
           $this->conn=new mysqli($config['host'],$config['user'],$config['password'],$config['database']);
           if ($this->conn->connect_error) {
               die("Connection failed: " . $this->conn->connect_error);
           }
       }

       public function query($query){
          $result=$this->conn->query($query);
           $rows=array();
           if ($result->num_rows > 0) {
               // 输出每行数据
               while($row = $result->fetch_assoc()) {
                      $rows[]=$row;
               }
           }
           return $rows;
       }

       public function excute($sql){
           return mysqli_query($this->conn,$sql);
       }

       public function close(){
           mysqli_close($this->conn);
       }
   }
?>